package org.creativor.rayson.client;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import java.net.InetSocketAddress;
import java.net.SocketAddress;
import org.creativor.rayson.api.AsyncRpcProtocol;
import org.creativor.rayson.api.RpcProtocol;
import org.creativor.rayson.api.TransferArgument;
import org.creativor.rayson.api.TransferSocket;
import org.creativor.rayson.demo.proxy.DemoTransferArgument;
import org.creativor.rayson.protocol.ServerProtocol;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;

/**
 * The class <code>RaysonTest</code> contains tests for the class
 * <code>{@link Rayson}</code>.
 * <p>
 * Copyright Creativor Studio (c) 2011
 * 
 * @generatedBy CodePro at 11-5-7 上午2:46
 * @author Nick Zhang
 * @version $Revision: 1.0 $
 */
public class RaysonTest
{
	/**
	 * Launch the test.
	 * 
	 * @param args
	 *            the command line arguments
	 * 
	 * @generatedBy CodePro at 11-5-7 上午2:46
	 */
	public static void main(String[] args)
	{
		new org.junit.runner.JUnitCore().run(RaysonTest.class);
	}
	
	/**
	 * Perform pre-test initialization.
	 * 
	 * @throws Exception
	 *             if the initialization fails for some reason
	 * 
	 * @generatedBy CodePro at 11-5-7 上午2:46
	 */
	@Before
	public void setUp() throws Exception
	{
		// TODO: add additional set up code here
	}
	
	/**
	 * Perform post-test clean-up.
	 * 
	 * @throws Exception
	 *             if the clean-up fails for some reason
	 * 
	 * @generatedBy CodePro at 11-5-7 上午2:46
	 */
	@After
	public void tearDown() throws Exception
	{
		// TODO: add additional tear down code here
	}
	
	/**
	 * Run the AsyncRpcProtocol
	 * createAsyncProxy(String,Class<T>,InetSocketAddress) method test.
	 * 
	 * @throws Exception
	 * 
	 * @generatedBy CodePro at 11-5-7 上午2:46
	 */
	@Test
	public void testCreateAsyncProxy_1() throws Exception
	{
		String serviceName = "";
		Class<AsyncRpcProtocol> proxyInterface = AsyncRpcProtocol.class;
		InetSocketAddress serverAddress = new InetSocketAddress(1);
		
		AsyncRpcProtocol result =
				Rayson.createAsyncProxy(serviceName, proxyInterface, serverAddress);
		
		// TODO: add additional test code here
		assertNotNull(result);
	}
	
	/**
	 * Run the AsyncRpcProtocol
	 * createAsyncProxy(String,Class<T>,InetSocketAddress) method test.
	 * 
	 * @throws Exception
	 * 
	 * @generatedBy CodePro at 11-5-7 上午2:46
	 */
	@Test
	public void testCreateAsyncProxy_2() throws Exception
	{
		String serviceName = "";
		Class<AsyncRpcProtocol> proxyInterface = AsyncRpcProtocol.class;
		InetSocketAddress serverAddress = new InetSocketAddress(1);
		
		AsyncRpcProtocol result =
				Rayson.createAsyncProxy(serviceName, proxyInterface, serverAddress);
		
		// TODO: add additional test code here
		assertNotNull(result);
	}
	
	/**
	 * Run the RpcProtocol createProxy(String,Class<T>,InetSocketAddress) method
	 * test.
	 * 
	 * @throws Exception
	 * 
	 * @generatedBy CodePro at 11-5-7 上午2:46
	 */
	@Test
	public void testCreateProxy_1() throws Exception
	{
		String serviceName = "";
		Class<RpcProtocol> proxyInterface = RpcProtocol.class;
		InetSocketAddress serverAddress = new InetSocketAddress(1);
		
		RpcProtocol result = Rayson.createProxy(serviceName, proxyInterface, serverAddress);
		
		// TODO: add additional test code here
		assertNotNull(result);
	}
	
	/**
	 * Run the RpcProtocol createProxy(String,Class<T>,InetSocketAddress) method
	 * test.
	 * 
	 * @throws Exception
	 * 
	 * @generatedBy CodePro at 11-5-7 上午2:46
	 */
	@Test
	public void testCreateProxy_2() throws Exception
	{
		String serviceName = "";
		Class<RpcProtocol> proxyInterface = RpcProtocol.class;
		InetSocketAddress serverAddress = new InetSocketAddress(1);
		
		RpcProtocol result = Rayson.createProxy(serviceName, proxyInterface, serverAddress);
		
		// TODO: add additional test code here
		assertNotNull(result);
	}
	
	/**
	 * Run the byte getClientVersion() method test.
	 * 
	 * @throws Exception
	 * 
	 * @generatedBy CodePro at 11-5-7 上午2:46
	 */
	@Test
	public void testGetClientVersion_1() throws Exception
	{
		
		byte result = Rayson.getClientVersion();
		
		// TODO: add additional test code here
		assertEquals((byte) 1, result);
	}
	
	/**
	 * Run the ServerProxy getServerProxy(InetSocketAddress) method test.
	 * 
	 * @throws Exception
	 * 
	 * @generatedBy CodePro at 11-5-7 上午2:46
	 */
	@Test
	public void testGetServerProxy_1() throws Exception
	{
		InetSocketAddress serverAddress = new InetSocketAddress(1);
		
		ServerProtocol result = Rayson.getServerProxy(serverAddress);
		
		// TODO: add additional test code here
		assertNotNull(result);
	}
	
	/**
	 * Run the ServerProxy getServerProxy(InetSocketAddress) method test.
	 * 
	 * @throws Exception
	 * 
	 * @generatedBy CodePro at 11-5-7 上午2:46
	 */
	@Test
	public void testGetServerProxy_2() throws Exception
	{
		InetSocketAddress serverAddress = new InetSocketAddress(1);
		
		ServerProtocol result = Rayson.getServerProxy(serverAddress);
		
		// TODO: add additional test code here
		assertNotNull(result);
	}
	
	/**
	 * Run the TransferSocket openTransferSocket(SocketAddress,TransferArgument)
	 * method test.
	 * 
	 * @throws Exception
	 * 
	 * @generatedBy CodePro at 11-5-7 上午2:46
	 */
	@Test(expected = java.net.ConnectException.class)
	public void testOpenTransferSocket_1() throws Exception
	{
		SocketAddress serverAddress = new InetSocketAddress(1);
		TransferArgument argument = new DemoTransferArgument("");
		
		TransferSocket result = Rayson.openTransferSocket(serverAddress, argument);
		
		// TODO: add additional test code here
		assertNotNull(result);
	}
	
	/**
	 * Run the TransferSocket openTransferSocket(SocketAddress,TransferArgument)
	 * method test.
	 * 
	 * @throws Exception
	 * 
	 * @generatedBy CodePro at 11-5-7 上午2:46
	 */
	@Test(expected = java.net.ConnectException.class)
	public void testOpenTransferSocket_2() throws Exception
	{
		SocketAddress serverAddress = new InetSocketAddress(1);
		TransferArgument argument = new DemoTransferArgument("");
		
		TransferSocket result = Rayson.openTransferSocket(serverAddress, argument);
		
		// TODO: add additional test code here
		assertNotNull(result);
	}
	
	/**
	 * Run the TransferSocket openTransferSocket(SocketAddress,TransferArgument)
	 * method test.
	 * 
	 * @throws Exception
	 * 
	 * @generatedBy CodePro at 11-5-7 上午2:46
	 */
	@Test(expected = java.net.ConnectException.class)
	public void testOpenTransferSocket_3() throws Exception
	{
		SocketAddress serverAddress = new InetSocketAddress(1);
		TransferArgument argument = new DemoTransferArgument("");
		
		TransferSocket result = Rayson.openTransferSocket(serverAddress, argument);
		
		// TODO: add additional test code here
		assertNotNull(result);
	}
	
	/**
	 * Run the TransferSocket openTransferSocket(SocketAddress,TransferArgument)
	 * method test.
	 * 
	 * @throws Exception
	 * 
	 * @generatedBy CodePro at 11-5-7 上午2:46
	 */
	@Test(expected = java.net.ConnectException.class)
	public void testOpenTransferSocket_4() throws Exception
	{
		SocketAddress serverAddress = new InetSocketAddress(1);
		TransferArgument argument = new DemoTransferArgument("");
		
		TransferSocket result = Rayson.openTransferSocket(serverAddress, argument);
		
		// TODO: add additional test code here
		assertNotNull(result);
	}
	
	/**
	 * Run the TransferSocket openTransferSocket(SocketAddress,TransferArgument)
	 * method test.
	 * 
	 * @throws Exception
	 * 
	 * @generatedBy CodePro at 11-5-7 上午2:46
	 */
	@Test(expected = java.net.ConnectException.class)
	public void testOpenTransferSocket_5() throws Exception
	{
		SocketAddress serverAddress = new InetSocketAddress(1);
		TransferArgument argument = new DemoTransferArgument("");
		
		TransferSocket result = Rayson.openTransferSocket(serverAddress, argument);
		
		// TODO: add additional test code here
		assertNotNull(result);
	}
	
	/**
	 * Run the void ping(SocketAddress) method test.
	 * 
	 * @throws Exception
	 * 
	 * @generatedBy CodePro at 11-5-7 上午2:46
	 */
	@Test(expected = org.creativor.rayson.exception.NetWorkException.class)
	public void testPing_1() throws Exception
	{
		SocketAddress serverAddress = new InetSocketAddress(1);
		
		Rayson.ping(serverAddress);
		
		// TODO: add additional test code here
	}
	
	/**
	 * Run the void ping(SocketAddress) method test.
	 * 
	 * @throws Exception
	 * 
	 * @generatedBy CodePro at 11-5-7 上午2:46
	 */
	@Test(expected = org.creativor.rayson.exception.NetWorkException.class)
	public void testPing_2() throws Exception
	{
		SocketAddress serverAddress = new InetSocketAddress(1);
		
		Rayson.ping(serverAddress);
		
		// TODO: add additional test code here
	}
}
